package org.hcyspartnoc.demo.mapper.system;

import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.hcyspartnoc.demo.pojo.po.system.SysRolePo;

import java.util.List;

@Mapper
public interface SysRoleMapper extends MPJBaseMapper<SysRolePo> {



    @Select("select role_id from sys_role_user where user_id=#{id}")
    List<Integer> selectByidUser(Integer id);

    @Select("select name from sys_role where id=#{roleid}")
    String selectByidRole(Integer roleid);

    @Select("select id from sys_role where name=#{name}")
    Integer selectroleid(String name);

    @Select("select permission_id from sys_role_permission where role_id=#{roleId}")
    List<Integer> selectperid(Integer roleId);

    @Select("select description from sys_permission where id=#{perid} ")
    String selectpername(Integer perid, Integer id);

    @Select("select description from sys_permission")
    List<String> selectallperName();

    @Delete("delete from sys_role_permission where role_id=#{roleid}")
    void deleteperbyid(Integer roleid);

    @Insert("insert into sys_role_permission (role_id, permission_id) VALUES (#{roleid},#{permission})")
    void insertidperandrole(Integer permission, Integer roleid);

    @Select("select name from sys_role ")
    List<String> selectRoles();

    @Delete("delete from sys_role where id=#{role}")
    void deletroleid(Integer role);
}
